let testEditor=document.getElementById("test-editor");
let textarea = document.getElementsByTagName('textarea')[1]
let D=document.getElementsByClassName("D")[0];
/*输入框显示时间为默认的文章描述*/
let InputValueTime=document.getElementsByClassName("InputValueTime")[0];
setInterval(function(){
    let date=new Date();
    let Month=date.getMonth()+1;
    let Day=date.getDate();
    let Year=date.getFullYear();
    if(Month<10)Month="0"+Month;
    if(Day<10)Day="0"+Day;
    let timeYMD=Year+"-"+Month+"-"+Day;
// console.log(timeYMD);
    InputValueTime.placeholder=timeYMD;
},1000);
/*文章标签*/
let labelNumber=0;
let tenLabel=document.getElementsByClassName("tenLabel");
let array=new Array(10);
for(let i=0;i<10;i++){
    array[i]=0;
}
for(let i=0;i<tenLabel.length;i++){
    click();
    function click(){
        tenLabel[i].onclick=function(){
            tenLabel[i].style.backgroundColor="#42bbfd";
            tenLabel[i].style.color="#ffffff";
            labelNumber++;
            /*点击那个数组相应位置为1，表示添加*/
            array[i]=1;
            tenLabel[i].onclick=function(){
                tenLabel[i].style.backgroundColor="";
                tenLabel[i].style.color="";
                labelNumber--;
                /*点击那个数组相应位置为1，表示删除*/
                array[i]=0;
                click();
            }
        }
    }
}

let tenLabelT=document.getElementsByClassName("tenLabelT");
let labelNumberT=0;
let arrayT=new Array(2);
for(let i=0;i<tenLabelT.length;i++){
    arrayT[i]=0;
}
for(let i=0;i<tenLabelT.length;i++){
    clickT();
    function clickT(){
        tenLabelT[0].onclick=function(){
            tenLabelT[0].style.backgroundColor="#42bbfd";
            tenLabelT[0].style.color="#ffffff";
            tenLabelT[1].style.backgroundColor="";
            tenLabelT[1].style.color="";
            labelNumberT=1;
            /*点击那个数组相应位置为1，表示添加*/
            tenLabelT[1].onclick=function(){
                tenLabelT[1].style.backgroundColor="#42bbfd";
                tenLabelT[1].style.color="#ffffff";
                tenLabelT[0].style.backgroundColor="";
                tenLabelT[0].style.color="";
                labelNumberT=2;
                clickT();
            }
        }
    }

/*昵称*/
let messageNameS=document.getElementsByClassName("messageNameS")[0];
/*发布文章按钮*/
let releaseArticle=document.getElementsByClassName("releaseArticle")[0];
let titleLength=document.getElementsByClassName("titleLength")[0];
/*点击判断输入框长度*/
releaseArticle.onclick=function(){
    if(InputValueTime.value.length<5||InputValueTime.value.length>60){
        set("标题字数应在5-60之间");
    }else if(labelNumber==0){
        set("请选择文章标签");
    }else if(labelNumberT==0){
        set("请选择文章类型");
    }else{
        /*这里是ajax点击发送请求*/
        /*文章内容textarea.innerText*/
        /*array()文章标签*/
        /*arrayT文章类型*/
        /*-其他数据可以从本地获取*/
        // console.log(textarea.innerText)
        $.ajax({
            url:"../blog/releaseBlog",
            type:"post",
            data:{
                blogger:messageNameS.innerHTML,
                content:textarea.innerText,
                toc:arrayT,
                type:array,
                title:InputValueTime.value
            },
            success:function(data){
                window.location.replace('../tooIndex');
                window.history.back(-1);
            }
        });
    }
}
function set(i){
    titleLength.innerHTML=i;
    titleLength.style.bottom="56px";
    setTimeout(function(){
        titleLength.style.bottom="-56px";
    },1000)
}
let headerPictureContainerS=document.getElementsByClassName("headerPictureContainers")[0];
headerPictureContainerS.style.display="none";